<?php

$username = $_POST['username'];
$password = $_POST['password'];

include("opendb.php");
include("functions.php");
$res = isValidUser($username,$password);
if($res!=1) {
echo "$username = $password";
exit;
}


$listing_id = $_POST['listing_ID'];
$image_id = $_POST['mainid'];

require('../db/opendb.php');

/* echo $_SESSION['id'];
echo "<BR>";
echo $id;*/


$lquery = "update Listing_Images set Main_Photo = '0' where Listing_ID = '".$listing_id."'";
$lresult = mysql_query($lquery) or die ("SQL Error".mysql_error());
//$row = mysql_fetch_assoc($lresult);

$sql = "update Listing_Images set Main_Photo = '1' where ID = '".$image_id."'";
$result = mysql_query($sql) or die ("SQL Error".mysql_error());


echo "1";



?>